//
//  ProductTableViewCell.m
//  HWZB
//
//  Created by 许成雄 on 2017/4/20.
//  Copyright © 2017年 wonders. All rights reserved.
//

#import "ProductTableViewCell.h"
#import "UIImageView+Webcache.h"

@interface ProductTableViewCell()

@property (strong, nonatomic) UIImageView *pictureImageView;
@property (strong, nonatomic) UILabel *titleLabel;
@property (strong, nonatomic) UILabel *descLabel;

@end

@implementation ProductTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self) {
        self.pictureImageView = [[UIImageView alloc] initWithFrame:CGRectMake(TRANS_VALUE(20.0f), TRANS_VALUE(10.0f), TRANS_VALUE(60.0f), TRANS_VALUE(60.0f))];
        self.pictureImageView.contentMode = UIViewContentModeScaleAspectFit;
        self.pictureImageView.clipsToBounds = YES;
        self.pictureImageView.layer.borderColor = I_COLOR_GRAY.CGColor;
        self.pictureImageView.layer.borderWidth = 0.0f;
        [self.contentView addSubview:self.pictureImageView];
        self.pictureImageView.image = [UIImage imageNamed:@"ic_mobilephone_default1"];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(TRANS_VALUE(100.0f), TRANS_VALUE(10.0f), TRANS_VALUE(220.0f), TRANS_VALUE(60.0f))];
        self.titleLabel.font = [UIFont boldSystemFontOfSize:TRANS_VALUE(13.0f)];
        self.titleLabel.textAlignment = NSTextAlignmentLeft;
        self.titleLabel.numberOfLines = 0;
        self.titleLabel.textColor = I_COLOR_33BLACK;
        self.titleLabel.text = @"荣耀 畅玩6X 4GB 32GB 全网通4G手机 高配版 铂光金";
        [self.contentView addSubview:self.titleLabel];
        
//        self.descLabel = [[UILabel alloc] initWithFrame:CGRectMake(TRANS_VALUE(90.0f), TRANS_VALUE(45.0f), TRANS_VALUE(220.0f), TRANS_VALUE(20.0f))];
//        self.descLabel.font = [UIFont systemFontOfSize:TRANS_VALUE(10.0f)];
//        self.descLabel.textAlignment = NSTextAlignmentLeft;
//        self.descLabel.textColor = I_COLOR_GRAY;
//        self.descLabel.text = @"已选: 铂光金 全网通(4GB 32GB)官方标配";
//        [self.contentView addSubview:self.descLabel];
        
    }
    self.contentView.backgroundColor = I_COLOR_WHITE;
    
    return self;
}

- (void)setImageUrl:(NSString *)imageUrl {
    _imageUrl = imageUrl;
    if(_imageUrl) {
        [self.pictureImageView sd_setImageWithURL:[NSURL URLWithString:_imageUrl] placeholderImage:[UIImage imageNamed:@"ic_mobilephone_default1"]];
    } else {
        self.pictureImageView.image = [UIImage imageNamed:@"ic_mobilephone_default1"];
    }
}

- (void)setProductName:(NSString *)productName {
    _productName = productName;
    if(_productName) {
        self.titleLabel.text = [NSString stringWithFormat:@"%@", _productName];
    } else {
        self.titleLabel.text = @"未知商品";
    }

}

- (void)awakeFromNib {
    // Initialization code
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
